﻿using System;
using System.Globalization;
using CAION2.Classes;
using FirstFloor.ModernUI.Presentation;

namespace CAION2.ViewModels
{
    class Main2ViewModel : ViewModelBase
    {
        #region Vars

        private string title;
        
        #endregion
        
        #region Properties

        

        public string Title
        {
            get
            {
                return this.title;
            }
            set
            {
                if (Equals(this.title, value)) return;
                this.title = value;

                this.OnPropertyChanged("Title");
            }
        }
        
        #endregion

        #region Commands

        #endregion

        internal Main2ViewModel()
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture
                = CultureInfo.GetCultureInfo(ClassConfiguration.GetValue("InterfaceLanguage").ToString());

            Title = Properties.Resources.Title;

            string themeColor = ClassConfiguration.GetValue("ThemeColor").ToString();
            switch (themeColor)
            {
                case "Dark":
                    AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource;
                    break;
                case "Light":
                    AppearanceManager.Current.ThemeSource = AppearanceManager.LightThemeSource;
                    break;
                default:
                    AppearanceManager.Current.ThemeSource = new Uri(themeColor, UriKind.RelativeOrAbsolute);
                    break;
            }
            
            string fontSize = ClassConfiguration.GetValue("FontSize").ToString();
            switch (fontSize)
            {
                case "Large":
                    AppearanceManager.Current.FontSize = FontSize.Large;
                    break;
                case "Small":
                    AppearanceManager.Current.FontSize = FontSize.Small;
                    break;
            }

            int colorIndex = (int)ClassConfiguration.GetValue("AccentColor");
            AppearanceManager.Current.AccentColor = SettingsViewModel.AccentColors[colorIndex];
        }
    }
}
